<template>
  <div class="container">
    <div class="title">要货单详情</div>
    <el-table max-height="600":data="conter"  style="width: 100%" empty-text="暂无数据">
      <el-table-column prop="apfromorgcode" label="订单code" align="center"></el-table-column>
      <el-table-column prop="id" label="ID" align="center"></el-table-column>
      <el-table-column prop="orgname" label="店铺名称" align="center"></el-table-column>
      <el-table-column prop="orgcode" label="店铺编码" align="center"></el-table-column>
      <el-table-column prop="status" label="货单状态" align="center"></el-table-column>
      <el-table-column prop="enquiry_time" label="要货时间" align="center"></el-table-column>
      <el-table-column prop="add_time" label="拉取时间" align="center"></el-table-column>
      
    </el-table>
    <el-table max-height="600":data="tableData"  style="width: 100%" empty-text="暂无数据">
      <el-table-column prop="productcode" label="商品code" align="center"></el-table-column>
      <el-table-column prop="productname" label="商品名称" align="center"></el-table-column>
      <el-table-column prop="unit" label="分类名称" align="center"></el-table-column>
      <el-table-column prop="qty" label="要货数量" align="center"></el-table-column>
      <el-table-column prop="pick_qty" label="配货数量" align="center"></el-table-column>
      <el-table-column prop="goods_price" label="价格" align="center"></el-table-column>
      <el-table-column prop="total_price" label="总价" align="center"></el-table-column>
    </el-table>
  </div>
</template>

<script>
import { findDelivery } from "@/api/delivery/deliveryList";
import { parseTime } from "@/utils/index";
export default {
  data() {
    return {
      tableData: [],
      conter: []
    };
  },

  created() {
    this.getData();
  },
  methods: {
    getData() {
      const data = {
        id: this.$route.query.id
      };
      findDelivery(data).then(res => {
        if (res.code == 0) {
          switch (res.data.info.status) {
            case 0:
              res.data.info.statusMsg = "待提交";
              break;
            case 1:
              res.data.info.statusMsg = "待发货";
              break;
            case 2:
              res.data.info.statusMsg = "已发货";
              break;
            case 3:
              res.data.info.statusMsg = "已收货";
              break;
          }
          this.tableData = res.data.info.orderGoods;
          this.conter.push ({
            apfromorgcode: res.data.info.apfromorgcode,
            orgname: res.data.info.orgname,
            orgcode: res.data.info.orgcode,
            status: res.data.info.statusMsg,
            enquiry_time: res.data.info.enquiry_time,
            add_time: parseTime(res.data.info.add_time),
            id:res.data.info.id
          });
          console.log(this.conter)
          setTimeout(() => {
            this.$nextTick(() => {
              window.print();
            });
          }, 1000);
        }
      });
    }
  }
};
</script>
<style scoped>
.container {
  width: 800px;
  margin: 0 auto;
}
.title {
  font-size: 20px;
  text-align: center;
  color: #222;
  font-weight: bold;
  padding: 40px;
}
</style>